import {defineStore} from 'pinia'
import {ExtType} from "@/types/project"

/**
 * 全局配置
 */
export default defineStore('app-ext', {
    state(): { ext: ExtType } {
        /**
         * 应用配置
         */
        const ext: ExtType = {
            name: "",
            desc: "",
            path: "",
            base_api: "",
            desktop: "",
            option:{}
        }
        return {ext}
    },

    getters: {
        /**
         * 获取主页路由
         */
        desktop(): string {
            return this.ext.desktop
        }
    },

    actions: {
        /**
         * 初始化全局应用配置
         * @param ext
         */
        setExtConfig(ext: ExtType) {
            for (let key in ext) {
                this.ext[key as keyof ExtType] = ext[key as keyof ExtType]
            }
        }
    }
})